package com.wwj.springboot.app.controller;
import com.wwj.springboot.app.common.R;
import com.wwj.springboot.entity.CmfzBanner;
import com.wwj.springboot.mapper.CmfzBannerMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wwj
 * @Api：修饰整个类，描述Controller的作用
 */
@Api(description = "app轮播图相关接口")
@RestController
@RequestMapping("/app/banner")
public class AppBannerController {
    @Autowired
    private CmfzBannerMapper cmfzBannerDao;

    /**
     * @ApiOperation：描述一个类的一个方法，或者说一个接口
     *
     * value
     * notes
     * produces 说明数据响应格式 application/json json
     *
     * @ApiParam：单个参数描述
     */
    @ApiOperation(
            value="获取轮播图数据",
            notes="获取轮播图数据",
            produces="application/json"
    )
    @GetMapping("/selectBanner/{size}/{username}")
    public R selectBanner(@PathVariable("size") Integer size, @PathVariable("username") String username){
        System.out.println(size);
        System.out.println(username);

        List<CmfzBanner> cmfzBanners = cmfzBannerDao.selectList(null);

//        数据通过R对象响应
        return R.ok().put("data",cmfzBanners);
    }
}
